from util import db, json, route

bp = route(__name__)

@bp.get("/")
async def index(request):
    # sql 注解 返回结果
    rs = db.result.all(as_dict=True)
    return json({"list": rs})

@bp.get("/edit/<id:int>")
async def edit(request, id):
    params = {
        'id': id
    }
    row = db.query('select * from moji where cityId = :id', **params).one().as_dict()
    return json({
        'index.py': 'edit',
        'data': row
    })